package com.hspedu.newData.dmsxl.栈;

import org.junit.Test;

import java.util.Stack;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-06 
 * @Version: 1.0
 */

public class LC2390从字符串中移除星号 {

    public String removeStars(String s) {

        StringBuilder sb = new StringBuilder();
        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (sb.length() != 0&&s.charAt(i) == '*'){
                sb.deleteCharAt(--index);
            }else {
                sb.append(s.charAt(i));
                index++;
            }
        }
        return sb.toString();
    }

    @Test
    public void test() {
        // 测试代码

        String s = removeStars("leet**cod*e");
        String s1 = removeStars("erase*****");
    }
}
